<%
   use_page_title"Reuse Content"
%>
<%= render layout: 'page_title' do %>
    <%= link_to "Back to Page", page_path(@page), class: 'btn btn-small right' %>
<% end %>

<%= form_tag new_connector_path, :method => :get do %>
    <%= hidden_field_tag :page_id, @page.to_param %>
    <%= hidden_field_tag :container, @container %>
    <div class="row-fluid padded">
      <label for="block_type">
        Choose Type of Content
        <%= select_tag "block_type", options_for_select(Cms::ContentType.connectable.to_a.map { |ct| [ct.display_name, ct.content_block_type] }, @block_type.content_block_type), :onchange => 'this.form.submit()' %>
      </label>
    </div>
<% end %>

<%= render layout: 'main_content' do %>
    <table class="table table-bordered">
      <thead>
      <tr>
        <th>Add?</th>
        <th>Name</th>
        <th>Updated</th>
        <th>Uses</th>
      </tr>
      </thead>
      <% @blocks.each do |block| %>
          <tr>
            <td><%= link_to "Add", connectors_path(page_id: @page.to_param, container: @container, :connectable_type => @block_type.content_block_type, connectable_id: block.id), class: "btn btn-mini btn-primary", method: :post %></td>
            <td><%= link_to block.name, engine_aware_path(block), target: '_blank' %></td>
            <td><%= block.updated_at.to_formatted_s(:date) %></td>
            <td><%= block.connected_pages.count %></td>
          </tr>
      <% end %>
    </table>
<% end %>